from django.utils import simplejson as json
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from lib.json import encode

class JsonHandler(webapp.RequestHandler):
    def get_params(self):
        return json.loads(self.request.body)
    
    def write(self, result):
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(encode(result))

class SessionHandler(JsonHandler):
    pass

app = webapp.WSGIApplication([
                              (r'/server/session/?([0-9]+)?', SessionHandler),
                            ], debug=True)

def main():
    run_wsgi_app(app)

if __name__ == '__main__':
    main()
